<?php

use App\Http\Controllers\UploadController; // 引入控制器
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;
use App\Http\Controllers\VoiceCloneController;
use App\Http\Controllers\TtsController;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider and all of them will
| be assigned to the "api" middleware group. Make something great!
|
*/

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

// --- 文件上传与管理路由 (使用控制器分组) ---
Route::controller(UploadController::class)->group(function () {
    // 文件上传路由
    Route::post('/upload', 'upload')->name('file.upload'); // 添加 name 便于生成 URL

    // 文件删除路由
    Route::post('/files/by-name', 'destroyByName')->name('file.destroy.by_name');
    Route::post('/files/by-url', 'destroyByUrl')->name('file.destroy.by_url');

    // 如果未来有统一的删除方法，可以这样定义:
    // Route::delete('/files', 'destroy')->name('file.destroy');
});

Route::prefix('voice-clone')->group(function () {
    Route::post('/train', [VoiceCloneController::class, 'train']);
    Route::post('/status', [VoiceCloneController::class, 'getStatus']);
});

// 语音合成相关路由
Route::prefix('tts')->group(function () {
    Route::post('/text-to-speech', [TtsController::class, 'textToSpeech']);
    Route::post('/generate-mp3', [TtsController::class, 'generateMp3FromBase64']);
});


